<template>
  <div class="container">
    <div class="title">
      <div class="img"></div>
      <h1>新型冠状病毒肺炎确诊患者同行程查询</h1>
      <div class="img2"></div>
    </div>
    <div class="inputArea">
      <form>
        查询：  <el-input  placeholder="请输入关键字" v-model="search" style="width:40%"></el-input>
        <el-button type="danger" @click="clear" style="margin-left:50px">清空</el-button>
        <el-button type="danger"  @click="reset">重置</el-button>
      </form>
    </div>
   <div class="option">
      <ul>
        <li @click="reset()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-quanbu"></use>
          </svg>
        </li>
        <li @click="findPlane()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-feiji"></use>
          </svg>
        </li>
        <li @click="findTrain()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-huoche"></use>
          </svg>
        </li>
        <li @click="findSubway()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-ditie"></use>
          </svg>
        </li>
        <li @click="findLBus()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-keche"></use>
          </svg>
        </li>
        <li @click="findBus()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-gongjiaoche"></use>
          </svg>
        </li>
        <li @click="findTaxi()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-chuzuche"></use>
          </svg>
        </li>
        <li @click="findShip()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-lunchuan"></use>
          </svg>
        </li>
        <li @click="findOther()">
          <svg class="font-icon" aria-hidden="true">
            <use xlink:href="#icon-gonggongchangsuojianceguanli"></use>
          </svg>
        </li>
      </ul>
    </div>

    <div class="table_list">
      <el-table
        :data="tables"
        height="580"
        style="width: 100%"
        :row-class-name="tableRowClassName"
        :default-sort="{ prop: 't_date', order: 'descending'}" 
      >
        <el-table-column label="线索来源">
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. who)" ></span >
          </template >
        </el-table-column>
        <el-table-column label="日期" >
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. t_date)" ></span >
          </template >
        </el-table-column>
        <el-table-column  label="车次/车牌/航班/场所名" >
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. t_no)" ></span >
          </template >
        </el-table-column>
        <el-table-column label="出行类型" >
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. t_type)" ></span >
          </template >
        </el-table-column>
        <el-table-column  label="出发站" >
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. t_pos_start)" ></span >
          </template >
        </el-table-column>
        <el-table-column  label="到达站" >
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. t_pos_end)" ></span >
          </template >
        </el-table-column>
        <el-table-column  label="车厢">
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. t_no_sub)" ></span >
          </template >
        </el-table-column>
        <el-table-column  label="出行描述">
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. t_memo)" ></span >
          </template >
        </el-table-column>
        <el-table-column label="提交时间" >
          <template slot-scope= "scope" >    
            <span class= "col-cont" v-html=" showDate( scope. row. created_at)" ></span >
          </template >
        </el-table-column>
        <el-table-column
          fixed="right"
          label="操作"
          width="100">
          <template slot-scope="scope">
            <el-button @click="openDetails(scope.row)" type="danger" size="small">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    
    <!-- 对话弹框 -->
    <el-dialog title="信息详情" :visible.sync="dialogTableVisible">
      <el-form v-model="detail">
        <el-form-item label="日期" :label-width="formLabelWidth">
          <el-input v-model="detail.t_date" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="线索来源" :label-width="formLabelWidth">
          <el-input v-model="detail.who" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="车次/车牌/航班/场所名" :label-width="formLabelWidth">
          <el-input v-model="detail.t_no" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="出行类型" :label-width="formLabelWidth">
          <el-input v-model="detail.t_type" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="出发站" :label-width="formLabelWidth">
          <el-input v-model="detail.t_pos_start" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="到达站" :label-width="formLabelWidth">
          <el-input v-model="detail.t_pos_end" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="车厢" :label-width="formLabelWidth">
          <el-input v-model="detail.t_no_sub" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="出行描述" :label-width="formLabelWidth">
          <el-input v-model="detail.t_memo" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="开始时间" :label-width="formLabelWidth">
          <el-input v-model="detail.t_start" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="结束时间" :label-width="formLabelWidth">
          <el-input v-model="detail.t_end" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="提交时间" :label-width="formLabelWidth">
          <el-input v-model="detail.created_at" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="来源网站" :label-width="formLabelWidth">
          <el-input v-model="detail.source" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 温馨提示 -->
    <div class="site-title">
    &nbsp;&nbsp;&nbsp;&nbsp;<b>特别提示：</b><br>
    &nbsp;&nbsp;&nbsp;&nbsp;<p>* 同乘人员、可能接触人员返家后，暂不要外出，居家封闭隔离观察。如有发热症状请就近到网上公布的指定医院发热门诊救治。</p>
    &nbsp;&nbsp;&nbsp;&nbsp;<p>* 就诊过程中，要全程佩戴口罩，尽量不要乘坐公共交通工具。</p>
    &nbsp;&nbsp;&nbsp;&nbsp;<p>* 同乘人员、可能接触人员要第一时间到所在社区进行登记，并与所在县（市）区疾病预防控制部门取得联系。</p>
    </div>

  </div>
</template>

<script>
import travel from "../../assets/travel.json";
export default {
  data() {
      return {
        dialogTableVisible: false,
        formLabelWidth: '150px',
        travel,
        old_travel:travel,
        search:'',
        detail:{},
      }
  },
  created(){
    this.reset()
  },
  computed: {
    tables:{
        get: function () {
          const search = this. search
          if (search) {
              return this. travel. filter( dataNews => {
                  return Object. keys(dataNews). some( key => {
                      return String(dataNews[key]). toLowerCase(). indexOf(search) > - 1
                  })
              })
          }
          return this. travel
        },
        set: function () {}
    }
    
  },
  watch:{
  },
  methods: {
     tableRowClassName({row, rowIndex}) {
        if (rowIndex%2=== 1) {
          return 'warning-row';
        } else {
          return 'success-row';
        }
        return '';
      },
    clear(){
      this.inputdate='',
      this.inputbus='',
      this.search=''
      this.reset()
    },
    findPlane(){
      
        this.reset()
        this.travel =this.travel.filter(item =>{
              return  item.t_type == "飞机"
        })
        this.tables=this.travel;
    },
    findTrain(){
      this.reset()
      this.travel =this.travel.filter(item =>{
               return item.t_type == "火车"
        })
      this.tables=this.travel;  
    },
    findSubway(){
      this.reset()
      this.travel =this.travel.filter(item =>{
               return item.t_type == "地铁"
        })
      this.tables=this.travel;  
    },
    findLBus(){
      this.reset()
      this.travel =this.travel.filter(item =>{
               return item.t_type == "长途客车/大巴"
        })
      this.tables=this.travel;  
    }, 
    findBus(){
      this.reset()
      this.travel =this.travel.filter(item =>{
               return item.t_type == "公交车"
        })
      this.tables=this.travel;
    },
    findTaxi(){
      this.reset()
      this.travel =this.travel.filter(item =>{
               return item.t_type == "出租车"
        })
      this.tables=this.travel;
    },
    findShip(){
      this.reset()
      this.travel =this.travel.filter(item =>{
               return item.t_type == "轮船"
        })
      this.tables=this.travel;
    },
    findOther(){
      this.reset()
      this.travel =this.travel.filter(item =>{
               return item.t_type == "其它公共场所"
        })
    },
    openDetails(row){
       this.dialogTableVisible=true;
       this.detail=row;
    },
    // 筛选变色
    showDate( val) {
        val = val + '';
        if ( val. indexOf( this. search) !== - 1 && this. search !== '') {
            return val. replace( this. search, '<font color="#409EFF">' + this. search + '</font>')
        } else {
            return val
        }
    },

    reset(){
      this.travel=this.old_travel;
    },

  },
};
</script>

<style>
.site-title{
  margin-top:30px ;
}
.font-icon {
  width: 2em;
  height: 2em;
  fill: currentColor;
  overflow: hidden;
}
.el-select{
    width: 150px;
    margin-top: 7px;
  }
.el-table .warning-row {
    background: oldlace;
  }
.el-table .success-row {
  background: #f0f9eb;
}
.option ul .select_item{
  float: right;
  height: 48px;
}
.option{
  height: 48px;
  background-color: #f2f2f2;
  margin-top:30px;
  margin-bottom:10px ;
}
.option ul{
  height: 48px;
  border-top: 1px solid rgb(224, 223, 223);
  border-bottom: 1px solid rgb(224, 223, 223);
  padding-left: 0;
}
.option ul li svg{
  margin-top: 10px;
}
.option ul li{
  float: left;
  height: 46px;
  line-height: 46px;
  min-width: 100px;
  padding: 0 20px;
  text-align: center;
  cursor: pointer;
  list-style: none;
}
.option ul li:hover{
  background-color: #fff;
}
.container .inputArea{
  padding-top: 30px;
}
.container .title h1{
  margin: 0;
  height: 220px;
  width: 800px;
  line-height: 220px;
  float: left;
}
.container .title .img{
  float: left;
  width: 300px;
  height: 300px; 
  background-image: url(../../assets/404_images/bingdu.png);
  background-size: 100% 100%;
}
.container .title .img2{
  width: 300px;
  height: 150px; 
  position: absolute;
  right: 0;
  top:295px;
  background-image: url(../../assets/404_images/train.png);
  background-size: 100% 100%;
}
.container .title {
  text-align: center;
  background-image: url(https://expertimg.cdn.bcebos.com/yidian%2Fa.png);
    background-size: 100% 100%;
    color: #fff;
    height: 250px;
    margin-bottom: 30px;
}

</style>
